Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add the capability to reload the current search #1515

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

manuel-cid
Copy link
Contributor

@manuel-cid manuel-cid commented Jun 11, 2024

Pull request template

We need a way to refresh the results displayed on the search layer.

Motivation and context

This requirement comes from the Backroom's next functionality, boost&bury of single products by query. After boosting or burying a product, we need a way to re-do the current search and refresh the results to see the change applied.
The idea is to emit the event ReloadSearchRequested through the x-bus and trigger a mutation on the state that triggers the search request.

  • Dependencies. If any, specify:
  • Open issue. If applicable, link:

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that causes existing functionality to not work as expected)
  • Change requires a documentation update

What is the destination branch of this PR?

  • Main
  • Other. Specify:

How has this been tested?

Tests performed according to testing guidelines:

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review on my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

@manuel-cid manuel-cid requested a review from a team as a code owner June 11, 2024 14:37
alvarodE
alvarodE previously approved these changes Jun 12, 2024
alvarodE
alvarodE previously approved these changes Jun 13, 2024
Comment on lines 50 to 51
const resettable = resettableState();
resettable.query = state.query;
resettable.facets = state.facets as never[];
resettable.sort = state.sort;
resettable.page = state.page;
Object.assign(state, resettable);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering a simpler implementation of this function and the only way I think it could be done would be like this, if you like it I leave it here to use it 😉

Suggested change
const resettable = resettableState();
resettable.query = state.query;
resettable.facets = state.facets as never[];
resettable.sort = state.sort;
resettable.page = state.page;
Object.assign(state, resettable);
const { query, facets, sort, page, ...resettable } = resettableState();
Object.assign(state, resettable);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@manuel-cid manuel-cid force-pushed the feat/reload-search branch 3 times, most recently from 6e11862 to 493563b Compare June 17, 2024 08:35
/**
* Reload the current search has been requested.
*/
ReloadSearchRequested: undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ReloadSearchRequested: undefined;
ReloadSearchRequested: void;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@manuel-cid manuel-cid force-pushed the feat/reload-search branch from 493563b to ab634d0 Compare June 17, 2024 08:55
@diegopf diegopf merged commit 617c3b0 into main Jun 17, 2024
4 checks passed
@diegopf diegopf deleted the feat/reload-search branch June 17, 2024 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants